<%@page import="java.util.ArrayList"%>
<%@page import="bean.guest_bookVO"%>
<%@page import="bean.guest_bookDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>너랑나랑 방명록</title>
<link rel = 'stylesheet' href = './css/style.css'/>
<script src = '/semy2/src/js/guest_book.js'> </script>
</head>
<body>
<jsp:useBean id="vo" class = "bean.guest_bookVO" scope="page"></jsp:useBean>
<jsp:setProperty property="*" name="vo"/>

<%
String m_id = (String)session.getAttribute("sessionMid");
guest_bookDTO dto = new guest_bookDTO();
vo.setM_id(m_id);
dto.setVo(vo);

ArrayList<guest_bookVO> al = dto.select_all();

%> 
<br/>
<div id = 'guest_book_top'>너랑 나랑 방명록</div>
<div id = 'guest_book_top_sub'>사랑을 남겨요~♥</div>
<!-- 방명록 입력 부분 -->
<div id = 'guest_book_input'>
	<label class = 'guest_book_m_id' name = 'm_id'><%=vo.getM_id() %></label>
	<div class = 'guest_book_g_date'></div>
	<input type = "button" id = 'bt_guest_book_input' value = '입력하기'/>
	<input type="text" name = "g_text" class = tf_guest_book_input" id = 'tf_guest_book_input'  placeholder = "내용을 입력해주세요."></input>
</div>
<br/>


<!-- 방명록 출력부분 -->
<% 
for(int a = 0; a<al.size();a++)
{
	guest_bookVO v = al.get(a);	
%>

	<div id = 'guest_book_output'>
		<div class = 'guest_book_g_rno'>NO.<%=v.getG_rno() %></div>
		<div class = 'guest_book_m_id'><b>아이디 :</b> <%=v.getM_id() %></div>
		<div class = 'guest_book_g_date'><%=v.getG_date() %></div>
		<div class = 'guest_book_g_nullblock'></div>	
<%if(v.getM_id().equals(vo.getM_id())) {%>
		<input type="image" src = './images/x_x_x2.png' class = 'bt_guest_book_del'  onclick = "guest_book_del(<%=v.getG_rno()%>);"/>
<%} %>
		<div class = 'guest_book_g_text'><%=v.getG_text() %></div>
	</div>

<br/>
<%} %>

<a href = '#' onclick = 'goPage(1)'>처음으로</a>
<% if(dto.getNow_page()>1){%>
<a href = '#' onclick = 'goPage(<%=dto.getNow_page()-1 %>)'>이전</a>
<%} %>
<%
int i = 0;
for(i = dto.getStart_page(); i<=dto.getEnd_page();i++){ %>
<a href = '#' onclick='goPage(<%=i%>)'> <%=i %></a>
<%}%>
<% if(dto.getNow_page()<dto.getTot_page()){%>
<a href = '#' onclick = 'goPage(<%=dto.getNow_page()+1%>)'>다음</a>
<%} %>
<a href = '#' onclick = 'goPage(<%=dto.getTot_page()%>)'>맨 끝으로</a>


<div>
	<input type = "button" id = 'bt_guest_book_gomain' value = '메인으로'/>
</div>


<form name = 'hidden_guest_book_frm' method  = 'post'>
	<input type="hidden" name='now_page' value="<%=vo.getNow_page()%>"/>
	<input type="hidden" name='m_id' value="<%=vo.getM_id()%>"/>
	<input type="hidden" name='g_text' value="<%=vo.getG_text()%>"/>
	<input type="hidden" name='g_rno' value="<%=vo.getG_rno()%>"/>
	
</form>

<form name='del_del' method="post" action="index.jsp?page_set=./guest_book/guest_book_del.jsp">
	<input type="hidden" name='g_rno'>
</form>
</body>
<script>guest_book_init();</script>
</html>